package com.itheima.reggie.dao;

import com.itheima.reggie.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;

public interface ShoppingCartDao {
    @Insert("insert into shopping_cart values(null,#{name},#{image},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    void add(ShoppingCart shoppingCart);

    ShoppingCart find(ShoppingCart shoppingCart);
    @Update("update shopping_cart set number=#{number} where id=#{id}")
    void update(ShoppingCart dbshoppingCart);

    @Select("select * from shopping_cart where user_id=#{userId}")
    List<ShoppingCart> findCart(Long userId);

    @Delete("delete from shopping_cart where user_id=#{userId}")
    void deleteAll(Long userId);
}
